from django.db import models

# Create your models here.

from django.contrib.auth.models import AbstractUser
from django.db import models


#
# # Create your models here.
#
# # 需要展示的就业信息内容包括:职位名称，工作性质，工作经验要求，月薪范围，学历要求，工作地点，招聘人数，发布日期，专业要求


class JobInfo(models.Model):
    """招聘"""
    name = models.CharField(max_length=255, null=False, verbose_name='职位名称')
    nature = models.CharField(max_length=255, null=False, verbose_name='工作性质')
    salary = models.CharField(max_length=20, verbose_name='月薪范围')
    degree_required = models.CharField(max_length=255, verbose_name='学历要求')
    location = models.CharField(max_length=255, verbose_name='工作地点')
    number = models.CharField(max_length=255, verbose_name='招聘人数')
    company = models.CharField(max_length=255, verbose_name='公司')
    request = models.CharField(max_length=255, verbose_name='专业要求')

    # create_time = models.CharField(max_length=20, verbose_name="发布日期")

    class Meta:
        db_table = 'workinfo_copy1'

    def __str__(self):
        return self.name


class User(AbstractUser):
    phone = models.CharField(max_length=11, unique=True, null=False, verbose_name='手机号')
    is_admin = models.IntegerField(default=0, verbose_name="是否为管理员")
    collection = models.ManyToManyField(JobInfo, through="user.Collection_job")

    class Meta:
        db_table = 'tb_users'
        verbose_name = '用户'


class Collection_job(models.Model):
    jobs = models.ForeignKey(JobInfo, on_delete=models.CASCADE, related_name='a')
    user_collection = models.ForeignKey(User, on_delete=models.CASCADE, related_name='b')

    class Meta:
        db_table = 'tb_collection'
